using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class _Default : System.Web.UI.Page 
{
    protected void Page_Load()
    {
        if (!IsPostBack)
        {
            // populate the TreeView from scratch
            TreeViewCategories.Nodes.Clear();
            List<NewsItem> allNews = News.GetAllNews(); // get root level ones
            foreach (NewsItem c in allNews)
            {
                TreeNode newNode = new TreeNode(c.Title, c.Id);
                newNode.SelectAction = TreeNodeSelectAction.SelectExpand;
                newNode.NavigateUrl = "News.aspx?catId=" + c.Id;
                TreeViewCategories.Nodes.Add(newNode);
            }

        }
    }

}
